import 'dart:async';

import 'package:flutter/material.dart';
import 'package:hotpot/route/route_ext.dart';
import 'package:hotpot/utils/user_utils.dart';
import 'package:hotpot/widgets/styles/icon_box.dart';
import 'package:hotpot/widgets/widget_ext.dart';
import 'package:hotpot/widgets/z_container.dart';

class SuccessWidget extends StatefulWidget {
  const SuccessWidget({super.key});

  @override
  State<SuccessWidget> createState() => _SuccessWidgetState();
}

class _SuccessWidgetState extends State<SuccessWidget> with TickerProviderStateMixin {
  late Timer timer;

  late AnimationController _settingController;

  @override
  void dispose() {
    // TODO: implement dispose
    timer.cancel();
    _settingController.dispose();
    super.dispose();
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _settingController = AnimationController(vsync: this, duration: const Duration(seconds: 1));
    timer = Timer(const Duration(minutes: 1), () => pop());
    _settingController.reset();
    _settingController.forward();
  }

  @override
  Widget build(BuildContext context) {
    return ZContainer(
      color: const Color(0xFFFFFFFF),
      child: Column(
        children: [
          106.hSizedBox,
          UserUtils.companyName.text(color: Colors.black, size: 16, bold: true),
          45.hSizedBox,
          const IconBox(
            Icons.check_circle,
            48,
            48,
            color: Color(0xFF22CE67),
            bgColor: Colors.transparent,
          ),
          // 'images/img_success.png'.assetImage(width: 48),
          17.hSizedBox,
          '¡Gracias por realizar tu pedido!\n\nLa cocina te está preparando la comida.'
              .text(size: 8, bold: true, color: Colors.black, maxLines: 5, textAlign: TextAlign.center),
          const SizedBox().expanded(),
          ZContainer(
            color: const Color(0xFF22CE67),
            height: 23,
            width: 82,
            radius: 18,
            alignment: Alignment.center,
            margin: const EdgeInsets.symmetric(horizontal: 25),
            child: 'Cerra'.text(size: 7, bold: true, color: Colors.white),
          ).gestureDetector(onTap: pop),
          15.hSizedBox,
        ],
      ),
    );
  }
}
